package com.liliya.dao.impl;

import com.liliya.dao.BaseDao;
import com.liliya.dao.RoleDao;
import com.liliya.pojo.Role;

import java.sql.SQLException;

/**
 * @Description TODO
 * @Author hhy
 * @Date 2021/1/6 15:15
 */
public class RoleDaoImpl extends BaseDao implements RoleDao {
    @Override
    public Role findRole(Integer num) {
        String sql = "select num,name from T_ROLE where num = ?";
        Role role = null;
        try {
            conn = getConn();
            pstm = conn.prepareStatement(sql);
            pstm.setInt(1,num);
            rs =  pstm.executeQuery();
            while (rs.next()){
                role = new Role(rs.getInt("num"),rs.getString("name"));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        close();
        System.out.println(sql);
        return role;
    }
}
